//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ScientificWorkflow.TridentModel
{
    #region Using Directives
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel; 
    #endregion

    /// <summary>
    /// This class represents databinding between 2 activities. 
    /// </summary>
    [Serializable]
    public class DatabindModel
    {
        #region private members

        /// <summary>
        /// The unique name of the source of the databind.
        /// </summary>
        string sourceActivityName;

        /// <summary>
        /// The property to be databound to.
        /// </summary>
        string sourcePropertyName;
        #endregion

        #region Constructors
        /// <summary>
        /// Constructor
        /// </summary>
        public DatabindModel(string sourceActivity, string sourceProperty)
        {
            #region Validation of Arguments
            if (string.IsNullOrEmpty(sourceActivity))
            {
                throw new ArgumentNullException("sourceActivity");
            }

            if (string.IsNullOrEmpty(sourceProperty))
            {
                throw new ArgumentNullException("sourceProperty");
            }
            #endregion

            // Set the source activity.
            this.SourceActivityName = sourceActivity;

            // Set the source property.
            this.SourcePropertyName = sourceProperty;
        }
        #endregion

        #region public properties

        /// <summary>
        /// Gets and sets the source activity for the binding.
        /// </summary>
        public string SourceActivityName
        {
            get
            {
                return sourceActivityName;
            }
            set
            {
                if (this.sourceActivityName != value)
                {
                    this.sourceActivityName = value;
                }
            }
        }

        /// <summary>
        /// Gets and sets the source property for the binding.
        /// </summary>
        public string SourcePropertyName
        {
            get
            {
                return sourcePropertyName;
            }
            set
            {
                if (this.sourcePropertyName != value)
                {
                    this.sourcePropertyName = value;
                }
            }
        }

        #endregion
    }
}
